﻿using ET;

namespace Core
{
    [Event]
    public class ItemChangeEvent : AEvent<ItemChange>
    {
        protected override async ETTask Run(ItemChange itemChange)
        {
            if (itemChange.container.Owner != Player.Instance.GetParent<Unit>())
                return;

            var window = await World.GetComponent<FGUIComponent>().GetWindowAsync<MainWindow>();
            if(window != null)
            {
                window.inventoryWidget.UpdateIndex(itemChange.slot.index);
            }
        }
    }
}
